package com.voxel.sense.infomsg.module.wifi;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.com.common.view.recycler.RecyclerAdapter;
import com.voxel.sense.infomsg.R;

import java.util.ArrayList;
import java.util.List;

import cyy.example.com.facotry.model.api.response.WifiWarnBean;

public class WifiWarnAdapter extends RecyclerView.Adapter<WifiWarnAdapter.WifiViewHolder> {


    private View view;

    private List<WifiWarnBean> list = new ArrayList<>();

    @Override
    public WifiViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycle_list_warn, parent, false);
        return new WifiViewHolder(view);
    }

    @Override
    public void onBindViewHolder(WifiViewHolder holder, int position) {
        WifiWarnBean wifiWarnBean = list.get(position);
        refreshData(holder, wifiWarnBean);
        picClickEvent(holder, wifiWarnBean);
    }

    private void picClickEvent(WifiViewHolder holder, WifiWarnBean wifiWarnBean) {

    }

    private void refreshData(WifiViewHolder holder, WifiWarnBean bean) {

        holder.tv_name.setText(bean.getCompanyName());
        holder.tv_category.setText(bean.getWatchsiteName());
        holder.tv_area.setText(bean.getDisconnectTimePeriod());
        holder.iv_level_icon.setText(bean.getDisconnectTime());

    }


    @Override
    public int getItemCount() {
        return list.size() > 0 ? list.size() : 0;
    }

    class WifiViewHolder extends RecyclerView.ViewHolder {
        ImageView iv_pic;//图片信息
        TextView iv_level_icon;//监管登记
        TextView iv_firm_type_icon;//监管级别
        TextView tv_name;//公司名称
        TextView tv_category;//行业类别
        TextView tv_area;//地址
        TextView tv_street;//街道
        TextView tv_over_numb;//超标次数
        TextView tv_ill_numb;//违规次数
        TextView tv_fault_numb;//故障次数

        private final Context mContext;

        public WifiViewHolder(View itemView) {
            super(itemView);
            mContext = itemView.getContext();
            iv_pic = itemView.findViewById(R.id.iv_pic);//图片信息
            iv_level_icon = itemView.findViewById(R.id.iv_level_icon);//监管登记
            tv_name = itemView.findViewById(R.id.tv_name);//公司名称
            iv_firm_type_icon = itemView.findViewById(R.id.iv_firm_type_icon);//监管级别
            tv_category = itemView.findViewById(R.id.tv_category);//行业类别
            tv_area = itemView.findViewById(R.id.tv_area);//区/
            tv_street = itemView.findViewById(R.id.tv_street);//街道
            tv_over_numb = itemView.findViewById(R.id.tv_over_numb);
            tv_ill_numb = itemView.findViewById(R.id.tv_ill_numb);
            tv_fault_numb = itemView.findViewById(R.id.tv_fault_numb);
        }
    };

    public void setData(List<WifiWarnBean> data) {
        this.list = data;
        notifyDataSetChanged();
    }

}
